﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace DelegatesTest
{
    class ThreadedButton
    {
        public ThreadedButton()
        {
            TheEvent += PrintToConsole;                        

            Thread t1 = new Thread(new ThreadStart(TheEvent));            
            Thread t2 = new Thread(new ThreadStart(TheEvent));

            t1.Start();
            t2.Start();
        }

        public delegate void MyVoidDelegate();

        public event MyVoidDelegate TheEvent;

        void PrintToConsole()
        {
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(i);
                Thread.Sleep(500);
            }
        }
    }
}
